<template>
  <div id="body">
    <div id="tou">
      <!-- <p id="hh" @click="backOff()">返回</p> -->
      <!-- <p id="jz">任务大厅</p> -->
    </div>
    <div
      class="kp"
      v-for="item in orderList"
      :key="item"
      @click="xq(item.ofId, haveOrder)"
    >
      <div class="clearfix">
        <div class="head">
          <img :src="item.userEntity.urAvatar" alt="" />
          <p>{{ item.ofTitle }}</p>
        </div>
        <div class="right">
          <div class="ztai">
            <p v-show="item.ofState == 1">未接单</p>
            <p v-show="item.ofState == 2">进行中</p>
            <p v-show="item.ofState == 3">待确认</p>
            <p v-show="item.ofState == 4">已完成</p>
          </div>
        </div>
      </div>
      <div class="body">
        <p class="ppp">
          {{ item.ofDescribe }}
        </p>
      </div>
      <div class="body">
        <p class="end">{{ item.ofLabel }}</p>
      </div>
      <div class="zf">
        <div class="qd">
          <div class="le">
            <p>￥{{ item.ofPrice }}</p>
          </div>
          <div class="qx" v-if="item.ofState == 1 && reId != 1">
            <p @click="jd(item.ofId)">接 单</p>
          </div>
        </div>
      </div>
    </div>
    <br /><br />
    <van-tabbar v-model="active">
      <van-tabbar-item icon="search"
        ><a href="https://xiaoqing.work/didi/" id="aa">首页</a></van-tabbar-item
      >
      <van-tabbar-item icon="friends-o">任务大厅</van-tabbar-item>
      <van-tabbar-item icon="friends-o" @click="bm">我要帮忙</van-tabbar-item>
      <van-tabbar-item @click="my">
        <span>我的</span>
        <template #icon="props">
          <img :src="props.active ? icon.active : icon.inactive" />
        </template>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
import { Toast } from "vant";
import api from "@/api/order";
import index from "@/api/index";
export default {
  created() {
    this.getlist();
    index.info(this.userID).then((res) => {
      this.reId = res.data.data.ddUser.reId;
    });
  },
  methods: {
    getlist() {
      api.lookAll().then((res) => {
        this.orderList = res.data.data.list;
      });
    },
    my() {
      this.$router.push("/PD");
    },
    bm() {
      this.$router.push("/UF");
    },
    jd(ofId) {
      var order = {
        ofId: ofId,
        ofState: 2,
      };
      api.updataOrder(order).then((res) => {
        this.getlist();
        this.$dialog({
          message: res.data.message,
        });
      });
    },
    qx(ofId) {
      var order = {
        ofId: ofId,
        ofState: 1,
      };
      api.updataOrder(order).then((res) => {
        this.getlist();
        this.$dialog({
          message: res.data.message,
        });
      });
    },
    backOff() {
      this.$router.go(-1);
    },
    // onClickLeft() {
    //   Toast("返回");
    // },
    xq(ofId, haveOrder) {
      var _this = this;
      setTimeout(() => {
        //设置延迟执行
        this.$router.push({
          path: "/XQ",
          query: {
            ofId: ofId,
          },
        });
      }, 1000);
    },
  },
  data() {
    return {
      active: 1,
      icon: {
        active: "https://img01.yzcdn.cn/vant/user-active.png",
        inactive: "https://img01.yzcdn.cn/vant/user-inactive.png",
      },
      userID: localStorage.getItem("tokenlo"),
      orderList: [],
      reId: "",
    };
  },
};
</script>

<style scope>
* {
  margin: 0;
  padding: 0;
}
#aa {
  color: #646566;
}
.clearfix:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}
.clearfix {
  *zoom: 1;
}
.kp {
  padding: 20px;
  width: 88%;
  height: 130px;
  margin: 0 auto;
  background-color: #fefefe;
  border-radius: 30px;
  box-shadow: 2px 2px 7px 0px #d1d1d1;
  margin-bottom: 10px;
}
.kp .head {
  float: left;
}
.ppp {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.kp .head img {
  width: 30px;
  height: 30px;
  vertical-align: middle;
  border-radius: 50%;
}
.kp .head p {
  display: inline-block;
  /* line-height: 30px; */
  margin-left: 10px;
  color: #232223;
  font-weight: 900;
}
.kp .right {
  float: right;
}
.kp .right .ztai {
  width: 67px;
  height: 32px;
  background-color: #f1fbfa;
}
.kp .right .ztai p {
  line-height: 32px;
  color: #5baa94;
  margin-left: 10px;
  font-size: 15px;
  font-weight: 800;
}
.kp .body {
  margin-top: 13px;
}
.kp .body p {
  color: #111111;
  margin-left: 20px;
  line-height: 30px;
}
.kp .body .end {
  color: #7b83ad;
  font-size: 14px;
  line-height: 3px;
}
.kp .zf .qd {
  float: right;
  width: 150px;
  height: 40px;
  /* background-color: pink; */
}
.kp .zf .qd .le {
  float: left;
  width: 76px;
  height: 40px;
  background-color: #fdf5f4;
  border-radius: 10px;
  line-height: 40px;
  color: #ba898e;
  font-size: 12px;
}
.kp .zf .qd .le p {
  margin-left: 6px;
}
.kp .zf .qd .qx {
  width: 50px;
  height: 38px;
  line-height: 40px;
  float: left;
  border: 1px solid #000;
  margin-left: 15px;
  border-radius: 10px 0 10px 0;
}
.kp .zf .qd .qx p {
  margin-left: 8px;
  font-size: 15px;
}
#body #tou {
  padding-bottom: 10px;
  padding-left: 10px;
  color: #3d3d3d;
}
#body #tou #hh {
  display: inline;
}
#body #tou #jz {
  margin-top: -19px;
  text-align: center;
}
#body {
  padding: 20px;
  background: #f9f9f9;
}
</style>